package com.zhentao.config;

import com.zhentao.service.ChatMessageService;
import com.zhentao.service.ChatGroupMessageService;
import com.zhentao.websocket.ChatEndpoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * WebSocket Bean配置
 * 确保WebSocket端点能够正确注入Spring管理的Bean
 */
@Configuration
public class WebSocketBeanConfig {

    /**
     * ServerEndpointExporter Bean
     * 自动注册@ServerEndpoint注解的WebSocket端点
     * 注意：这里启用ServerEndpointExporter，删除WebSocketConfig中的重复配置
     */
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }

    /**
     * ChatEndpoint Bean
     * 确保ChatEndpoint被Spring容器管理
     */
    @Bean
    public ChatEndpoint chatEndpoint() {
        return new ChatEndpoint();
    }
}